PSA Object Model Diagrams

CreateProjectFromTemplateService

global with sharing class CreateProjectFromTemplateService

a service used to clone one or more projects from templates. you can use this service in conjunction with sobjectclonemapper, as the mappers on a clone request, to add extra fields to objects or extra objects that are copied from the template. You must include the fields describing the relationship between extra objects and the template project.
For example, to copy a new custom object with a Project lookup field to a cloned project, add a mapper to the request and add all the fields to copy from the custom object, including the lookup field.

Methods

createProjectsFromTemplates

global static List<CreateProjectFromTemplateService.CreateProjectResponse> createProjectsFromTemplates(List<CreateProjectFromTemplateService.CreateProjectFromTemplateRequest> requests)

This method creates new projects from a project template using details provided in the CreateProjectFromTemplateRequest list. The following configuration is used:
• budget-name-suffix
• default-budget-status
• default-budget-type
• default-is-active
• default-time-credited
• default-time-excluded
• default-is-billable

Input Parameters

Name Type Description
requests List<CreateProjectFromTemplateService.CreateProjectFromTemplateRequest> The list of CreateProjectFromTemplateRequests.

Return Value

This service returns CreateProjectResponses in a list that parallels the input list.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

createProjectsFromTemplates

global static List<CreateProjectFromTemplateService.CreateProjectResponse> createProjectsFromTemplates(List<CreateProjectFromTemplateService.CreateProjectFromTemplateAndAccountRequest> requests)

This method creates new projects from a project template using details provided in the requests list. The project will be linked to the account Id passed in the CreateProjectFromTemplateAndAccountRequest. The following configuration is used:
• budget-name-suffix
• default-budget-status
• default-budget-type
• default-is-active
• default-time-credited
• default-time-excluded
• default-is-billable

Input Parameters

Name Type Description
requests List<CreateProjectFromTemplateService.CreateProjectFromTemplateAndAccountRequest> The list of CreateProjectFromTemplateAndAccountRequests.

Return Value

This service returns CreateProjectResponses in a list that parallels the input list.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

createProjectsFromTemplates

global static List<CreateProjectFromTemplateService.CreateProjectResponse> createProjectsFromTemplates(List<CreateProjectFromTemplateService.CreateProjectFromTemplateAndOpportunityRequest> requests)

This method creates new projects from a template project using details provided in the CreateProjectFromTemplateAndOpportunityRequest list. The project will be linked to the opportunity Id passed in the CreateProjectFromTemplateAndOpportunityRequest. The following configuration is used:
• project-name-suffix
• budget-name-suffix
• default-budget-status
• default-budget-type
• default-is-active
• default-time-credited
• default-time-excluded
• default-is-billable
• create-project-with-no-opp-update-permission

Input Parameters

Name Type Description
requests List<CreateProjectFromTemplateService.CreateProjectFromTemplateAndOpportunityRequest> The list of CreateProjectFromTemplateAndOpportunityRequest.

Return Value

This service returns CreateProjectResponses in a list that parallels the input list.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

CreateProjectFromTemplateService.CreateProjectRequest

global abstract class CreateProjectRequest

the request structure for the createprojectfromtemplateservice.

Properties

Name Type Description
IsActive Boolean indicates if the cloned project is active.
IsTemplate Boolean indicates if the cloned project is marked as a template.
ProjectName String indicates the name of the cloned project.
ProjectOwnerId Id the project owner id.
StartDate Date the intended project start date. this is also used to calculate a date offset value to update other project and related object date fields.
If the Work_Calendar__c field on Project_Task__c sObject has been included in either Project Task field set or passed as a Mapper on this request then Project Tasks will be adjusted into working time after the offset has applied. This will determine which days are working days according to the Work_Calendar__c on each Project Task.
TemplateProjectId Id the template project id used as a template to create a new project. any data described by the mappers must have a relationship with this record (or a sequence of relationships that can be followed to the record) or that data is not copied.
Mappers List<SObjectCloneMapper> the sobjectclonemapper list defining which fields are copied for which sobjects when creating a new project from a template. This is in addition to the default objects and fields as well as the fields contained in the 'CreateProjFromTemp' field sets.
UseCurrentTimePeriod Boolean set to true to ensure the cloned project is in the current time period.

CreateProjectFromTemplateService.CreateProjectFromTemplateRequest

global with sharing class CreateProjectFromTemplateRequest extends CreateProjectRequest

the request structure for creating projects from templates only. to be used with createprojectsfromtemplates.

This class extends CreateProjectFromTemplateService.CreateProjectRequest

Methods

CreateProjectFromTemplateRequest

global CreateProjectFromTemplateRequest(Id templateProjectId, Date startDate)

A default constructor with minimum required properties.

Input Parameters

Name Type Description
templateProjectId Id The project template id.
startDate Date The intended project start date.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

CreateProjectFromTemplateService.CreateProjectFromTemplateAndAccountRequest

global with sharing class CreateProjectFromTemplateAndAccountRequest extends CreateProjectRequest

the request structure for creating projects from templates with certain data coming from an account. To be used with createProjectsFromTemplatesAndAccounts.

This class extends CreateProjectFromTemplateService.CreateProjectRequest

Properties

Name Type Description
AccountId Id the account id.

Methods

CreateProjectFromTemplateAndAccountRequest

global CreateProjectFromTemplateAndAccountRequest(Id accountId, Id templateProjectId, Date startDate)

A default constructor with minimum required properties.

Input Parameters

Name Type Description
accountId Id The account id.
templateProjectId Id The project template id.
startDate Date The intended project start date.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

CreateProjectFromTemplateService.CreateProjectFromTemplateAndOpportunityRequest

global with sharing class CreateProjectFromTemplateAndOpportunityRequest extends CreateProjectRequest

the request structure for creating projects from templates with certain data coming from an opportunity. To be used with createProjectsFromTemplatesAndOpportunities.

This class extends CreateProjectFromTemplateService.CreateProjectRequest

Properties

Name Type Description
OpportunityId Id the opportunity id.

Methods

CreateProjectFromTemplateAndOpportunityRequest

global CreateProjectFromTemplateAndOpportunityRequest(Id opportunityId, Id templateProjectId, Date startDate)

A default constructor with minimum required properties.

Input Parameters

Name Type Description
opportunityId Id The opportunity Id.
templateProjectId Id The project template Id.
startDate Date The intended project start date.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

CreateProjectFromTemplateService.CreateProjectResponse

global class CreateProjectResponse

the response structure returned for each request passed to createprojectsfromtemplates.

Properties

Name Type Description
Request CreateProjectFromTemplateService.CreateProjectRequest the request associated with the response of createprojectfromtemplateservice.
NewProjectId Id the new project id. this may be set even though issuccess is false.
Errors List<CreateProjectFromTemplateService.CreateProjectError> stores error messages that occur when executing methods from createprojectfromtemplateservice.
QueuedJobId Id the createprojectfromtemplateservice may spawn a queueable to complete the work in a later transaction. When this occurs, this is the Id of the AsyncApexJob controlling the work. The record can be queried to monitor its status.

Methods

isSuccess

global Boolean isSuccess()

Indicates whether the project was successfully created. Even if isSuccess() is false, it is possible that the project was still created. That can happen, for example, when the there was a problem creating a budget to link to the new project.

CreateProjectFromTemplateService.CreateProjectError

global with sharing class CreateProjectError

stores error messages that occur when executing methods from createprojectfromtemplateservice.

Properties

Name Type Description
Message String the error message.
© Copyright 2009–2021 FinancialForce.com, inc. Confidential – all rights reserved. Various trademarks held by their respective owners.